//
//  LDSBaseUIViewController.m
//  LDSSmartHome
//
//  Created by leedarson on 2017/9/20.
//  Copyright © 2017年 leedarson. All rights reserved.
//

#import "LDSBaseUIViewController.h"
@interface LDSBaseUIViewController ()

@end

@implementation LDSBaseUIViewController

- (void)viewDidLoad {
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];//RGB(235, 241, 241) ;
    [super viewDidLoad];
    
    [self initNavigationItem];
    
    if([UIViewController instancesRespondToSelector:@selector(edgesForExtendedLayout)])
    {
        //view边缘线贴屏幕底部边缘线
        self.edgesForExtendedLayout = UIRectEdgeBottom;
    }
}

- (void)loadView {
    [super loadView];
    
    [self initNavigationItem];
    
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self hiddenTabar:[self tabbarHidden]];
    
}


- (BOOL)tabbarHidden {
    return YES;
}



- (void)hiddenTabar:(BOOL)hidden {
//    NSObject <LDSTabbarServiceProtocol> *obj = [[BeeHive shareInstance] createService:@protocol(LDSTabbarServiceProtocol)];
//    if ([obj isKindOfClass:[UITabBarController class]]) {
//        obj.isHidden = hidden;
//    }
}

- (void)initNavigationItem {
    NSString    *titleString = [self barItemTitle];
    if ([titleString length] > 0)
    {
        [self.navigationItem setTitle:titleString];
    }
    
    UIBarButtonItem *barButton = [self leftBarButtonItem];
    if (barButton)
    {
        [self.navigationItem setLeftBarButtonItem:barButton];
    }
    
    barButton = [self rightBarButtonItem];
    if (barButton)
    {
        [self.navigationItem setRightBarButtonItem:barButton];
    }
}

- (NSString *)barItemTitle {
    return nil;
}

- (UIBarButtonItem *)leftBarButtonItem {
    return nil;
}

- (UIBarButtonItem *)rightBarButtonItem {
    return nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

//以下回调必须在工程plist文件中设置“View controller-based status bar appearance”为YES
- (BOOL)prefersStatusBarHidden {
    return NO;
}

//以下回调必须在工程plist文件中设置“View controller-based status bar appearance”为YES
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

- (void)dealloc {
    NSLog(@"%@ delloc",NSStringFromClass([self class]));
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
